syntax on
filetype plugin indent on

autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif

set encoding=utf-8
set fileencoding=utf-8
" cp936 is gbk, euc-cn is gb2312
set fileencodings=utf-8,cp936,euc-cn,gb18030,iso-8859-2
set noerrorbells
set mouse=a
set autochdir

" ======== indent settings ========
set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab
set smarttab

autocmd Filetype markdown,html,xml,yaml,toml,svg
    \ setlocal tabstop=2 softtabstop=2 shiftwidth=4

set autoindent
set smartindent
set cindent
set shiftround

"autocmd Filetype html,xml,yaml setlocal tabstop=2 softtabstop=2 shiftwidth=2
autocmd Filetype go setlocal noexpandtab

set foldmethod=syntax
set foldlevel=80
"set clipboard=unnamed,unnamedplus

set number
set relativenumber
set nolist

set cursorline
set nocursorcolumn

set textwidth=80
autocmd Filetype java,javascipt,html setlocal textwidth=120

"set colorcolumn=+1
"highlight! ColorColumn ctermbg=lightgrey guibg=lightgrey
"highlight! Cursorline cterm=none ctermbg=236 guibg=Gray90
"highlight! CursorlineNr cterm=none ctermfg=159 ctermbg=236 guibg=Gray90
set laststatus=2
set scrolloff=4
set ruler
set wrap
set linebreak
set display+=lastline
set showcmd
set wildmenu
set wildmode=list:longest,full

set hlsearch
set incsearch
set ignorecase
set smartcase

"highlight! Search cterm=bold

set backspace=indent,eol,start

" ========== key board map =========
noremap <up> :resize -1<cr>
noremap <down> :resize +1<cr>
noremap <left> :vertical resize -1<cr>
noremap <right> :vertical resize +1<cr>

nnoremap <m-h> <c-w>h
nnoremap <m-l> <c-w>l
nnoremap <m-j> <c-w>j
nnoremap <m-k> <c-w>k

noremap <m-j> gj
noremap <m-k> gk

noremap <space><cr> :nohlsearch<cr>
noremap <leader><leader> <esc>/<++><cr>:nohlsearch<cr>c4l

vnoremap <c-c> "+y
inoremap <c-v> <esc>"+pi

au BufNewFile,BufRead *.tpl,*.dwt setfiletype php
au BufNewFile,BufRead SConstruct,SConscript setfiletype python

set background=dark
set termguicolors
packadd! dracula
colorscheme dracula

"function! GitBranch()
  "return system("git rev-parse --abbrev-ref HEAD 2>/dev/null | tr -d '\n'")
"endfunction

"function! StatuslineGit()
  "let l:branchname = GitBranch()
  "return strlen(l:branchname) > 0?'  '.l:branchname.' ':''
"endfunction

"set statusline=
"set statusline+=%#StatusLine#
"set statusline+=%{StatuslineGit()}
"set statusline+=%#Directory#
"set statusline+=\ %f
"set statusline+=%m
"set statusline+=%=
"set statusline+=%#IncSearch#
"set statusline+=\ %y
"set statusline+=\ %{&fileencoding?&fileencoding:&encoding}
"set statusline+=\[%{&fileformat}\]
"set statusline+=\ %p%%
"set statusline+=\ %l:%c
"set statusline+=\ 

highlight  Normal              guibg=NONE   ctermbg=NONE
highlight  SignColumn          guibg=NONE   ctermbg=NONE
highlight  DiffAdd             guibg=NONE   ctermbg=NONE
highlight  DiffDelete          guibg=NONE   ctermbg=NONE
highlight  DiffChange          guibg=NONE   ctermbg=NONE
highlight  SignifyLineDelete   guibg=NONE   ctermbg=NONE
highlight  SignifyLineChange   guibg=NONE   ctermbg=NONE

